function saveFile(refunwarpphase, phase, time, savePath, MASK)
    addpath('..\Algorithm\GoldsteinUnwrap2D_r1');
    addpath('..\Algorithm\WPCA');
    MASK(isnan(MASK)) = 0;
    im_mask = MASK;
    unwarpphase = GoldsteinUnwrap2D_r1(phase, im_mask);
    
%     refunwarpphase = imgaussfilt(refunwarpphase,[5,5]);
%     unwarpphase = imgaussfilt(unwarpphase,[5,5]);
%     figure;mesh(unwarpphase);title('unwarpphase');
    refunwarpphase = refunwarpphase - mean(mean(refunwarpphase,"omitnan"),"omitnan");
    unwarpphase = unwarpphase - mean(mean(unwarpphase,"omitnan"),"omitnan");
    unwarpphase = adjustPiston(refunwarpphase, unwarpphase);
%     figure;mesh(unwarpphase - refunwarpphase);
    rmse = sqrt(mean(mean((refunwarpphase-unwarpphase).^2,"omitnan"),"omitnan"));
    save([savePath,'\rmse.mat'],"rmse");
    save([savePath,'\time.mat'],"time");
end